package com.cardbaobao.cardbabyclient.ui.activity;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.util.TypedValue;
import android.view.View;

import com.cardbaobao.cardbabyclient.R;
import com.cardbaobao.cardbabyclient.ui.activity.base.BaseActivity;
import com.cardbaobao.cardbabyclient.widget.TitleBar;
import com.gyf.barlibrary.ImmersionBar;

import net.lucode.hackware.magicindicator.MagicIndicator;
import net.lucode.hackware.magicindicator.ViewPagerHelper;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.CommonNavigator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.CommonNavigatorAdapter;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.abs.IPagerTitleView;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.indicators.LinePagerIndicator;
import net.lucode.hackware.magicindicator.buildins.commonnavigator.titles.SimplePagerTitleView;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Jiangzx on 2018/3/22 12:04.
 */

public class CashCouponActivity extends BaseActivity {
    @BindView(R.id.title_bar)
    TitleBar titleBar;

    @BindView(R.id.magic_indicator)
    MagicIndicator indicator;

    @BindView(R.id.view_pager)
    ViewPager viewPager;

    List<String> title;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_cash_coupon;
    }

    @Override
    protected void initView(Bundle savedInstanceState) {
        super.initView(savedInstanceState);
        ImmersionBar.with(this).statusBarDarkFont(true).init();
        titleBar.setLeftViewOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });

        // TODO: 2018/3/22  
        //初始化指示器
        title=new ArrayList<>();
        title.add("未使用(2)");
        title.add("已使用(2)");
        title.add("已过期(2)");
        final CommonNavigator navigator=new CommonNavigator(mContext);
        navigator.setAdapter(new CommonNavigatorAdapter() {
            @Override
            public int getCount() {
                return title.size();
            }

            @Override
            public IPagerTitleView getTitleView(Context context, int i) {
                SimplePagerTitleView titleView=new SimplePagerTitleView(context);
                titleView.setNormalColor(0xff222222);
                titleView.setSelectedColor(0xffff9e27);
                titleView.setTextSize(TypedValue.COMPLEX_UNIT_SP,14);
                titleView.setText(title.get(i));
                return titleView;
            }

            @Override
            public IPagerIndicator getIndicator(Context context) {
                return null;
            }
        });
        navigator.setAdjustMode(true);
        indicator.setNavigator(navigator);
        ViewPagerHelper.bind(indicator,viewPager);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {
        super.initData(savedInstanceState);
    }
}
